package com.itheima.controller;


import com.github.pagehelper.Page;
import com.itheima.entity.PageResult;
import com.itheima.entity.Result;
import com.itheima.pojo.WebVisit;
import com.itheima.service.WebVisitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * Web访问记录表 前端控制器
 * </p>
 *
 * @author wangchang
 * @since 2020-08-04
 */
@Controller
@RequestMapping("/webVisit")
@CrossOrigin(allowCredentials="true", allowedHeaders="*", methods={RequestMethod.GET,RequestMethod.POST}, origins="*")
public class WebVisitController {

    @Autowired
    private WebVisitService webVisitService;
    
    // 获取分页访问列表
    @PostMapping("/getList")
    public Result getList(@RequestBody Map<String, Object> searchMap) {
        Page<WebVisit> pageList = webVisitService.getPageList(searchMap);
        PageResult pageResult = new PageResult(pageList.getTotal(), pageList.getResult());

        return new Result("success",pageResult);
    }
}

